<extend name="Public:company_center"/>

<block name="right_main">
<style>
	.icon-job-post-step {
		background-size: 965px 31px;
		background-repeat: no-repeat;
		background-position: 25% 0;
		width: 965px;
		height: 31px;
		margin: 0 auto;
	}
</style>
<if condition="$_GET['cid'] neq ''">
<!--发布职位-->
<div class="col-xs-15 col-md-10 wei-user-admin-content"><h3 class="wei-user-admin-title-bar">发布职位</h3>

	<div class="icon-job-post-step step-2" style="display: block"></div>
	<form class="form-horizontal" method="post" action="{:U('Job/insert')}" id="jobForm">
		<input type="hidden" name="cid" value="{$Think.get.cid}">
		<div class="form-group">
			<label class="col-sm-2 control-label">职位分类&nbsp;<span>*</span></label>

			<div class="col-sm-10"><p class="form-control-static">
				<span>{:cateBread($_GET['cid'])}</span>&nbsp;
				<a href="{:U('Job/add')}" class="text-primary">重新选择</a></p>
			</div>
		</div>
		<div class="form-group">
			<label class="col-sm-2 control-label">
				职位名称&nbsp;<span>*</span>
			</label>

			<div class="col-sm-5">
				<input class="form-control" type="text" name="name" value="" placeholder="必填"></div>
		</div>
		<div class="form-group"><label class="col-sm-2 control-label">
			月薪&nbsp;<span>*</span>
		</label>

			<div class="col-sm-5 form-inline">
				<input class="form-control" style="width:80px;" type="text" name="payid" value="" placeholder="数字">&nbsp;K&nbsp;
				<span>（1K = 1000元）</span><span class="help-block"></span></div>
		</div>
		<div class="form-group"><label class="col-sm-2 control-label">招聘人数&nbsp;<span>*</span></label>

			<div class="col-sm-5 form-inline">
				<input class="form-control" style="width: 60px; " type="text" name="num" value="" placeholder="数字">&nbsp;
			</div>
		</div>
		<div class="form-group"><label class="col-sm-2 control-label">所在城市&nbsp;<span>*</span></label>

			<div class="col-sm-5"><select class="form-control" name="cityid">
				<foreach name="city" item="v">
					<option value="{$v.id}" >{$v.name}</option>
				</foreach>
			</select></div>
		</div>
		<div class="form-group"><label class="col-sm-2 control-label">最低学历&nbsp;<span>*</span></label>

			<div class="col-sm-5"><select class="form-control" name="eid">
				<foreach name="edu" item="v">
					<option value="{$v.id}">{$v.tagname}</option>
				</foreach>
			</select></div>
		</div>
		<div class="form-group"><label class="col-sm-2 control-label">最低工作年限&nbsp;<span>*</span></label>

			<div class="col-sm-5"><select class="form-control" name="year">
				<foreach name="year" item="v">
					<option value="{$v.id}">{$v.tagname}</option>
				</foreach>
			</select></div>
		</div>
		<div class="form-group"><label class="col-sm-2 control-label">岗位职责&nbsp;<span>*</span></label>

			<div class="col-sm-8">
				<textarea class="form-control" rows="8" cols="30" name="duty" placeholder="必填（无需包含“岗位职责”、“主要职责”等字样）"></textarea>
				<span class="help-block">无需包含“岗位职责”、“主要职责”等字样</span>
			</div>
		</div>
		<div class="form-group">
			<label class="col-sm-2 control-label" for="requirement">任职要求&nbsp;<span>*</span></label>

			<div class="col-sm-8">
				<textarea class="form-control" rows="8" cols="30" id="requirement" name="request" placeholder="必填（无需包含“任职要求”、“要求”等字样）"></textarea><span class="help-block">无需包含“任职要求”、“要求”等字样</span>
			</div>
		</div>
		<div class="form-group"><label class="col-sm-2 control-label">&nbsp;</label>

			<div class="col-sm-10">
				<button type="submit" class="btn btn-primary">发布</button>
				&nbsp;
				<button type="button" class="btn btn-default" onclick="history.go(-1)">取消</button>
			</div>
		</div>
	</form>

</div>
<elseif condition="$_GET['id'] neq ''"/>
<!--填写标题党-->
<div class="col-xs-15 col-md-10 wei-user-admin-content"><h3 class="wei-user-admin-title-bar">设置标题党</h3>
	<div class="icon-job-post-step step-3" style="display: block"></div>
	<form class="form-horizontal" id="jobForm" method="post" action="{:U('job/update')}" >
		<input type="hidden" name='id' value="{$Think.get.id}"/>
		<input type="hidden" name='done' value="add"/>
		<div class="form-group"><label class="col-sm-2 control-label" >职位名称</label>
			<div class="col-sm-10">
				<label class="checkbox" style="padding-left:0px;">
				<span >{$name}</span></label>
			</div>
		</div>
		<div class="form-group">
			<label class="col-sm-2 control-label" for="thread_title">标题党&nbsp;<span>*</span></label>
			<div class="col-sm-8">
				<input class="form-control" type="text" name="title" value="" placeholder="必填"></div>
		</div>
		<div class="form-group"><label class="col-sm-2 control-label">&nbsp;</label>
			<div class="col-sm-10">
				<button type="submit" class="btn btn-primary">完成</button>
				&nbsp;
			</div>
		</div>
	</form>
	<script>
	</script>
</div>
<else/>
<!--选择分类-->
<div class="col-xs-15 col-md-10 wei-user-admin-content">
	<style type="text/css">
		select {
			width: 220px;
			border: 1px solid #cccccc;
			background-color: #ffffff;
		}

	</style>
	<h3 class="wei-user-admin-title-bar">职位分类</h3>
	<div class="icon-job-post-step step-1" style="display: block"></div>
	<form class="form-horizontal" id="form" method="get" action="{:U('Job/add')}">
		<input type="hidden" id="cid" name="cid" value="">
		<div class="form-group"><label class="col-sm-2 control-label">职位分类&nbsp;<span>*</span></label>
			<div class="col-sm-10">
				<select size="10" id="category_1">
					<foreach name="list" item="v">
						<option value="{$v.id}">{$v.name}</option>
					</foreach>
				</select> &nbsp;
				<select size="10" id="category_2"></select> &nbsp;
				<select size="10" id="category_3"></select></div>
		</div>
		<div class="form-group"><label class="col-sm-2 control-label">已选定分类</label>

			<div class="col-sm-10">
				<label class="checkbox" style="padding-left:0px;">
						<span id="category_name">
							<span>未选定</span>
						</span>
				</label>
			</div>
		</div>
		<div class="form-group"><label class="col-sm-2 control-label">&nbsp;</label>

			<div class="col-sm-10">
				<button type="submit" class="btn btn-primary">选定分类</button>
				&nbsp;
				<button type="button" class="btn btn-default" onclick="history.go(-1)">取消</button>
			</div>
		</div>
	</form>
	<script>
		seajs.use(['$'], function ($) {
			var cates = {};
			$.ajax({
				url : "{:U('Job/getCate')}",
				datatype : "json",
				async : false,
				success : function (data) {
					if ( data ) {
						cates = data;
					}
				}
			})
			$("#category_1").change(function () {
				$("#category_2").find("option").remove();
				$("#category_3").find("option").remove();
				for (var i = 0; i < cates.length; i++) {
					if ( cates[i].id == $(this).val() && cates[i].children.length > 0 ) {
						var cate_2 = cates[i].children;
						for (var j = 0; j < cate_2.length; j++) {
							$("#category_2").attr("data-pid", cate_2[j].pid);
							$("#category_2").append("<option value='" + cate_2[j].id + "'>" + cate_2[j].name + "</option>");
						}
					}
				}
			});
			$("#category_2").change(function () {
				$("#category_3").find("option").remove();
				for (var i = 0; i < cates.length; i++) {
					if ( cates[i].id == $(this).attr("data-pid") ) {
						var cate_2 = cates[i].children;
						for (var x = 0; x < cate_2.length; x++) {
							if ( $(this).val() == cate_2[x].id && cate_2[x].children.length > 0 ) {
								var cate_3 = cate_2[x].children;
								for (var j = 0; j < cate_3.length; j++) {
									$("#category_3").attr("data-pid", cate_3[j].pid);
									$("#category_3").append("<option value='" + cate_3[j].id + "'>" + cate_3[j].name + "</option>");
								}
							}
						}

					}
				}
			})
			$("#category_3").change(function () {
				$("input#cid").val($(this).val());
				var txt = $(this).find("option:selected").text();
				$("#category_name").html('<span class="label label-danger">' + txt + '</span>');
			})
			$("form#form").submit(function () {
				if ( !$("input#cid").val() ) {
					alert("请选择分类");
					return false;
				}
			})
		});
	</script>
</div>
</if>
<script>
	seajs.use(['$', 'bootbox', 'form-ajax'], function () {
		$(function () {
			var ajaxFrom = $('#jobForm');
			ajaxFrom.ajaxForm({
				dataType : 'json',
				success : function (data) {
					if ( data.status > 0 && data.url ) {
						window.location.href = data.url;
					} else {
						bootbox.alert({
							message : data.info,
							title : "提示信息"
						});
						return false;
					}
				}
			})
		})
	});
</script>
</block>